<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">

    <title>增加产地</title>

    <meta name="keywords" content="">
    <meta name="description" content="">

    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->

    <link rel="shortcut icon" href="favicon.ico"> <link href="__STATIC__/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__STATIC__/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="__STATIC__/css/animate.css" rel="stylesheet">
    <link href="__STATIC__/css/style.css?v=4.1.0" rel="stylesheet">
    <style type="text/css">
        div{
            text-align: center;
        }
        td{
            width: 8%;
            text-align: center;
        }
        .fanye{
            text-align: center;
        }
        .teacase{
            width: 5%;
            float: left;
            text-align: left;
            display: block;
        }
        .teaarea{
            width: 10%;
            float: left;
            text-align: left;
        }
        .teaarea1{
            width: 90%;
            float: left;
            text-align: left;
            overflow: hidden;
            display: inline;
        }
        .del{
            width:;
            color:red;
            cursor: pointer;
        }
        .add{
            width: 2%;
            height: 20px;
            float: left;
            font-size: 16px;
            cursor: pointer;
        }
        .source{
            width: 90%;
        }

    </style>
</head>
<body>
    <div class="ibox-title">
        <h5>产地管理</h5>
    </div>
    {foreach $caseAreas as $caseArea}
    <div class="ibox-content ">
        <label class="col-sm-3 control-label teacase">
        {$caseArea.teacase}
        </label>

        <div style="display: block;width: 94%;float: right;">
            {foreach $caseArea.areas as $area}
            <div class="teaarea" tid="{$caseArea.tid}" >
                <div class="teaarea1" style="height: 20px;">
                    {if $area.display==1}
                        <input type="checkbox" tid="{$caseArea.tid}" aid="{$area.aid}" display="{$area.display}" checked>
                    {else /}
                        <input type="checkbox" tid="{$caseArea.tid}" aid="{$area.aid}" display="{$area.display}">
                    {/if}
                    {$area.area}
                </div>
                {if($Think.session.user.grade==1)}
                    <span class='del' tid="{$caseArea.tid}" aid="{$area.aid}" data-toggle="modal"  data-target="#del">x</span>
                {/if}
                <input class="source" type="text" tid="{$caseArea.tid}" aid="{$area.aid}" style="margin-bottom: 10px;" value="{$area.source}" data-toggle="modal"  data-target="#modifysource">
            </div>
            {/foreach}
            <div class="add" tid="{$caseArea.tid}" data-toggle="modal"  data-target="#addmod">+</div>
            <div style="clear: both;"></div>
        </div>
    </div>
    {/foreach}

<form action="insertArea">
    <div class="modal fade" id="addmod" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myModalLabel">增加产区</h4>
                </div>
                <div class="modal-body">
                    <input type="hidden" name="tid">
                    <div>产区名称：<input type="text" name="area"></div><br>
                    <div>词条来源：<input type="text" name="source"></div>

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button type="submit" class="btn btn-primary">确定</button>
                </div>
            </div>
        </div>
    </div>
</form>

<form action="delArea">
    <div class="modal fade" id="del" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myModalLabel">删除后不能恢复</h4>
                </div>
                <div class="modal-body">
                    <input type="hidden" name="dtid">
                    <input type="hidden" name="daid">
                    确定删除吗？
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button type="submit" class="btn btn-primary">确定</button>
                </div>
            </div>
        </div>
    </div>
</form>

<form action="mdsource" method="post">
    <div class="modal fade" id="modifysource" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myModalLabel">修改来源</h4>
                </div>
                <div class="modal-body">
                    <input type="hidden" name="tid">
                    <input type="hidden" name="aid">
                    <input type="text" name="source" value="">
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button type="submit" class="btn btn-primary">确定</button>
                </div>
            </div>
        </div>
    </div>
</form>

<!-- 全局js -->
<script src="__STATIC__/js/jquery.min.js?v=2.1.4"></script>
<script src="__STATIC__/js/bootstrap.min.js?v=3.3.6"></script>
<script type="text/javascript">

$(".add").click(function(){
    var tid = $(this).attr('tid');
    $('input[name=tid]').val(tid);
})

$("span.del").click(function(){
    var tid = $(this).attr('tid');
    var aid = $(this).attr('aid');
    $("input[name=dtid]").val(tid);
    $("input[name=daid]").val(aid);
})



$("input[type=checkbox]").click(function(){
    var tid = $(this).attr('tid');
    var aid = $(this).attr('aid');
    var display =  $(this).attr('display');
    if(display==1){
        $(this).attr('display',0);
    }else{
        $(this).attr('display',1);
    }

    var data = {
        tid:tid,
        aid:aid,
        display:display
    }
    var url = "{:url('displayarea')}";
    $.post(url, data, function(data){
        if(data==1){
            alert('修改成功');
        }
    });
})

$(".source").click(function(){
    var tid = $(this).attr('tid');
    var aid = $(this).attr('aid');
    var source = $(this).val();
    $('#modifysource input[name=tid]').val(tid);
    $('#modifysource input[name=aid]').val(aid);
    $('#modifysource input[name=source]').val(source);
});



</script>

</body>
</html>